/* GUI CONVERTED from rcsddela.p (converter v1.75) Thu Jul 19 05:35:15 2001 */
/* rcsddela.p - Release Management Customer Schedules                        */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                       */
/* All rights reserved worldwide.  This is an unpublished work.              */
/* $Revision: 1.11.1.2 $                                                 */
/*V8:ConvertMode=Maintenance                                                 */
/* REVISION: 7.3      LAST MODIFIED: 08/13/93   BY: WUG *GE19*               */
/* REVISION: 7.3      LAST MODIFIED: 04/14/94   BY: WUG *GJ35*               */
/* REVISION: 7.3      LAST MODIFIED: 09/11/94   BY: rmh *GM22*               */
/* REVISION: 7.5      LAST MODIFIED: 10/27/95   BY: dpm *J044*               */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan        */
/* Old ECO marker removed, but no ECO header exists *F0PN*              */
/* REVISION: 8.6E     LAST MODIFIED: 07/15/98   BY: *L024* Bill Reckard      */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb               */
/* $Revision: 1.11.1.2 $  BY: Ellen Borden  DATE: 07/09/01   ECO: *P007* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}

/* DELETE A SO LINE ITEM RECORD SUBPROGRAM */

define input parameter sodnbr like sod_nbr.
define input parameter sodline like sod_line.

{gpfilev.i}
/* DETERMINE IF CONTAINER AND LINE CHARGES IS ENABLED */
{cclc.i}

find sod_det where sod_nbr = sodnbr
   and sod_line = sodline exclusive-lock.
find so_mstr where so_nbr = sod_nbr exclusive-lock.

if using_line_charges then do:
   /*DELETE LINE CHARGE RECORDS*/
   {gprunmo.i
      &program = ""sosodlcd.p""
      &module = "ACL"
      &param = """(input sodnbr, input sodline)"""}
end.
/*DELETE LINE ITEM COMMENTS */
for each cmt_det where cmt_indx = sod_cmtindx exclusive-lock:
   delete cmt_det.
end.

/*DELETE ALLOCATION DETAIL*/
for each lad_det where lad_dataset = "sod_det"
      and lad_nbr     = sod_nbr
      and lad_line    = string(sod_line) exclusive-lock:
   find ld_det where ld_site = lad_site
      and ld_loc  = lad_loc
      and ld_lot  = lad_lot
      and ld_ref  = lad_ref
      and ld_part = lad_part.
   ld_qty_all = ld_qty_all - (lad_qty_all + lad_qty_pick).
   delete lad_det.
end.

find scx_ref
   where scx_type = 1 and scx_order = sod_nbr and scx_line = sod_line
   exclusive-lock no-error.

if available scx_ref then delete scx_ref.

/* DELETE IMPORT EXPORT RECORDS */
find first ied_det exclusive-lock where
   ied_type = "1" and ied_nbr = so_nbr and ied_line = sod_line
   no-error.
if available ied_det then delete ied_det.
delete sod_det.

/* DELETE HEADER IF NO MORE RECORDS */
find first sod_det where sod_nbr = sodnbr no-lock no-error.

if not available sod_det then do:

   /*DELETE ORDER COMMENTS */
   for each cmt_det where cmt_indx = so_cmtindx exclusive-lock:
      delete cmt_det.
   end.

   find first ie_mstr exclusive-lock where
      ie_type = "1" and ie_nbr = so_nbr no-error.
   if available ie_mstr then delete ie_mstr.

   {gprunp.i "mcpl" "p" "mc-delete-ex-rate-usage"
      "(input so_exru_seq)" }

   delete so_mstr.
end.
